package com.ruoyi.supplier.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.supplier.domain.TbPriceStore;
import com.ruoyi.supplier.service.ITbPriceStoreService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 库存明细Controller
 * 
 * @author ruoyi
 * @date 2021-05-10
 */
@RestController
@RequestMapping("/supplier/priceStore")
public class TbPriceStoreController extends BaseController
{
    @Autowired
    private ITbPriceStoreService tbPriceStoreService;

    /**
     * 查询库存明细列表
     */
    @PreAuthorize("@ss.hasPermi('supplier:priceStore:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbPriceStore tbPriceStore)
    {
        startPage();
        List<TbPriceStore> list = tbPriceStoreService.selectTbPriceStoreList(tbPriceStore);
        return getDataTable(list);
    }

    /**
     * 导出库存明细列表
     */
    @PreAuthorize("@ss.hasPermi('supplier:priceStore:export')")
    @Log(title = "库存明细", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TbPriceStore tbPriceStore)
    {
        List<TbPriceStore> list = tbPriceStoreService.selectTbPriceStoreList(tbPriceStore);
        ExcelUtil<TbPriceStore> util = new ExcelUtil<TbPriceStore>(TbPriceStore.class);
        return util.exportExcel(list, "priceStore");
    }

    /**
     * 获取库存明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('supplier:priceStore:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tbPriceStoreService.selectTbPriceStoreById(id));
    }

    /**
     * 新增库存明细
     */
    @PreAuthorize("@ss.hasPermi('supplier:priceStore:add')")
    @Log(title = "库存明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbPriceStore tbPriceStore)
    {
        return toAjax(tbPriceStoreService.insertTbPriceStore(tbPriceStore));
    }

    /**
     * 修改库存明细
     */
    @PreAuthorize("@ss.hasPermi('supplier:priceStore:edit')")
    @Log(title = "库存明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbPriceStore tbPriceStore)
    {
        return toAjax(tbPriceStoreService.updateTbPriceStore(tbPriceStore));
    }

    /**
     * 删除库存明细
     */
    @PreAuthorize("@ss.hasPermi('supplier:priceStore:remove')")
    @Log(title = "库存明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{id}")
    public AjaxResult remove(@PathVariable Long[] id)
    {
        return toAjax(tbPriceStoreService.deleteTbPriceStoreByIds(id));
    }
}
